package com.gitee.wsl.struct.tree.sample.link

import com.gitee.wsl.struct.tree.Tree
import com.gitee.wsl.struct.tree.builder.LinkTreeBuilder
import com.gitee.wsl.struct.tree.builder.buildTree

class LinkTree<T> internal constructor(
    override val children: List<LinkTreeElement<T>>
) : Tree<T, LinkTreeElement<T>>(children) {

    companion object {
        internal val EMPTY = LinkTree(children = emptyList<LinkTreeElement<Any?>>())

        fun <T> emptyTree(): LinkTree<T> = EMPTY as LinkTree<T>

        operator fun <T> invoke(builder: LinkTreeBuilder<T>.() -> Unit) = buildTree(builder)
    }
}